<%@page import="bean.B01boardDTO"%>
<%@page import="bean.B01boardVO" %>
<%@page import="java.util.ArrayList" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>List</title>
<link rel="stylesheet" href="./css/B01board.css">
<script src = './js/B01board.js'></script>
</head>
<body>
<jsp:useBean id="vo" class="bean.B01boardVO" scope="page"/>
<jsp:setProperty property="*" name="vo"/>
<%
B01boardDTO dto = new B01boardDTO();
dto.setVo(vo);
ArrayList<B01boardVO> al = dto.select();
%>

<h1 id="title" align="center" style="color: #0080ff;">자 유 게 시 판</h1>
<hr id="title_boardLine" style="border-color: #0080ff;"/>
<div id = 'wrap' align="center" style="font-size: small;">
	<form name = 'hiddenFrm' method='post'>
		 	<input type='hidden' name="nowPage">
		 	<input type='hidden' name='find'>
		 	<input type='hidden' name='b_number'>
	</form>

	<p/>
	<div class = 'list_title'>
		<div id='list_b_number'>글번호</div>
		<div id='list_b_title'>제목</div>
		<div id='list_m_id'>글쓴이</div>
		<div id='list_b_date'>작성일</div>
		<div id='list_b_image'>파일</div>
	</div>
<%
	for(int a=0; a<al.size(); a++){ 
		B01boardVO v = al.get(a);
%>
 <div class="list_items">
		<div id='list_b_number'><%=v.getB_number()%></div>
		<div id='list_b_title'> <!-- 실제 클릭되는 값   -->
			
			<a href = '#' onclick="<%if(session.getAttribute("sessionMid") == null || session.getAttribute("sessionMid").equals("")){%>
										gologin(<%=dto.getNowPage()%>,<%=v.getB_number()%>)"><%=v.getB_title()%>
								   <%}else{%>
								   		goView(<%=dto.getNowPage()%>,<%=v.getB_number()%>)"><%=v.getB_title()%>
								   <%}%>	
<%-- 			<% 	if(v.getB_title().length()>20){
				String title = v.getB_title().substring(0, 20); %>
		    	<%=title%>...
			<%} else {%>
				<%=v.getB_title()%>
			<%}%> --%>
			</a>
		</div>
		<div id='list_m_id'><%=v.getM_id()%></div>
		<div id='list_b_date'><%=v.getB_date()%>
<%-- 			<% 	String date = (String)v.getB_date();
				if(date.length()>10){
				String date1 = date.substring(0, 10); %>
		    	<zz%=date1%>
			<%} else {%>
				<%=v.getB_date()%>
			<%}%> --%>
		</div>
		<div id='list_b_modifyDate'><%=v.getB_modifyDate()%></div>
		<div id='list_b_image'>		
		<% if(v.getB_image()!= null){%>	
			 <% if(v.getB_image().length()>15){
				String image = v.getB_image().substring(0, 15); %>
		    	<%=image%>..
			<%}else{%>
				<%=v.getB_image()%> 
			<%}%>	
		<%}else{%>
			파일없음
		<%}%>
		</div>
	</div>	
<%}%>	
</p>
<div id = 'list_page' align="center">
		<% if(dto.getNowPage()==1){%>
		[처음으로]
		<%}else{%><a href='#' onclick='goPage(1)'>[처음으로]  </a>
		<%}%>
		
	<% if(dto.getNowBlock()==1){%>
		[이전으로]
		<%}else{%><a href="#" onclick='goPage(<%=dto.getStartPage()-1 %>)'>[이전으로]</a>
		<%} %>	
	<%	
	int i=0;
	for(i = dto.getStartPage(); i<=dto.getEndPage(); i++){%>
	<a href= "#" onclick = "goPage(<%= i %>)"><%= i %></a>
	<%} %>
	<% if(dto.getNowBlock()==dto.getTotBlock()){%>
		[다음으로]
		<%}else{%><a href= '#' onclick = "goPage(<%=i %>)">  [다음으로]</a>
		<%} %>
	
	<% if(dto.getNowPage()==dto.getTotPage()){%>
		[맨끝으로]
		<%}else{%><a href= "#" onclick = "goPage(<%=dto.getTotPage() %>)">  [맨끝으로]</a>
		<%} %>	
	
</div>
	<p/>
	<div align="center"> 
		<form action="index1.jsp?inc=./Community/list.jsp" name ='board_list_frm' method = 'post'>
			<input type="text" name = 'find' value ="<%=vo.getFind()%>" size="60"/>
			<input type="submit" value='검색'>
		</form>
	<%if(session.getAttribute("sessionMid") == null || session.getAttribute("sessionMid").equals("") ){ %>
		<input type="button" value="새 글쓰기" id="btnNotInput" style="margin-right: 1000px;">
	<%}else{ %>
		<input type="button" value="새 글쓰기" id="btnInput"/>
	<%} %>
	</div>
	<p/>
	<hr id="title_boardLine" style="border-color: #0080ff;"/>
</div>	
</body>
<script>listInit();</script>
</html>